#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define D long double
#define N 500005
struct node{
	int x,id;
}a[N];
bool cmp(node a,node b){
	return a.x<b.x;
}
int can[N],b[N],cnt,c[N];
signed main(){
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++)	cin>>a[i].x,b[i]=a[i].x,a[i].id=i;
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=k;i++){
		can[a[i].id]=1;
	}
	for(int i=1;i<=n;i++)if(can[i]){
		c[++cnt]=b[i];
	}
	int mx=-1;
	for(int i=1;i<=k;i++){
		mx=max(mx,c[i]+c[i%k+1]);
	}
	cout<<mx;
	return 0;
}

